package cn.syc.struck.demo;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.view.MenuItem;

import cn.syc.struck.demo.base.BaseActivity;
import cn.syc.struck.demo.dummy.DummyContent;
import cn.syc.struck.demo.fragment.AppsFragment;
import cn.syc.struck.demo.fragment.ItemFragment;
import cn.syc.struck.demo.fragment.LinearFragment;
import cn.syc.struck.demo.fragment.ListFragment;

public class NavigationActivity extends BaseActivity implements ItemFragment.OnListFragmentInteractionListener {

    //private TextView mTextMessage;

    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    //mTextMessage.setText(R.string.title_home);
                    getSupportFragmentManager().beginTransaction().replace(R.id.content, ItemFragment.newInstance(1), "fragment").commit();
                    return true;
                case R.id.navigation_dashboard:
                    //mTextMessage.setText(R.string.title_dashboard);
                    getSupportFragmentManager().beginTransaction().replace(R.id.content, new LinearFragment(), "fragment").commit();
                    return true;
                case R.id.navigation_notifications:
                    //mTextMessage.setText(R.string.title_notifications);
                    getSupportFragmentManager().beginTransaction().replace(R.id.content, new AppsFragment(), "fragment").commit();
                    return true;
                case R.id.navigation_me:
                    //mTextMessage.setText(R.string.title_notifications);
                    getSupportFragmentManager().beginTransaction().replace(R.id.content, new ListFragment(), "fragment").commit();
                    return true;
            }
            return false;
        }

    };

    @Override
    protected int getLayoutId() {
        return R.layout.activity_navigation;
    }

    @Override
    protected void afterCreate(Bundle savedInstanceState) {
        //mTextMessage = (TextView) findViewById(R.id.message);
        BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
        //----------------
        getSupportFragmentManager().beginTransaction().add(R.id.content, ItemFragment.newInstance(1), "fragment").commit();
    }

    @Override
    public void onListFragmentInteraction(DummyContent.DummyItem item) {

    }

}
